#ifndef _SENSOR_H
#define _SENSOR_H

#include "STC8A.h"

#define SENSOR_CH1    0
#define SENSOR_CH2    1
#define SENSOR_CH3    2
#define SENSOR_CH4    3

typedef struct {
    u8 heat_voltage;
    FLOAT32 ref_resistor;
    FLOAT32 base_resistor;
} SENSOR_PARA_T;

typedef struct {
    FLOAT32 resistance;
    u16 voltage;
    FLOAT32 concentration;
} SENSOR_DATA_T;

typedef struct {
    FLOAT32 calibration_conc[6];
    FLOAT32 calibration_resp[6];
} CALIBRATION_DATA_T;

typedef struct {
    float calibration_k[5];
    float calibration_b[5];
} CALIBRATION_KBS_T;


extern SENSOR_PARA_T sensor_parameters[4];
extern SENSOR_DATA_T sensor_data[4];
extern CALIBRATION_DATA_T calibration_data[4];
extern CALIBRATION_KBS_T calibration_kbs[4];

extern float mems_vol[4];
extern u8 sensor_type;

void sensor_init();

void updata_sensor_data();

void set_sensor_heat_voltage(u8 sensor_ch, u8 heat_voltage);

void set_sensor_ref_resistor(u8 sensor_ch, FLOAT32* ref_resistor);

void set_sensor_base_resistor(u8 sensor_ch, FLOAT32* base_resistor);

void compute_calibration_kbs(u8 sensor_ch, FLOAT32 conc[], FLOAT32 resp[]);

#endif
